'''
生成数据 100 *
u(t) = Random(0, 1) * 0.5
x(t) = f = u(t) * (x(t - 1) + 1 / (x(t - 1) + y(t - 1) + u(t)))
t(t) = g  = x(t - 1) / x(t - 1) + y(t - 1) + u(t)
'''

import numpy as np

# 保留5位小数
def round_5(data):
    data = map(lambda x: round(x, 5), data)
    data = np.array(list(data))
    return data


u = np.random.random(size=(100,)) * 0.5
u = round_5(u)
x = np.zeros(100)
y = np.zeros(100)
x[0] = u[0] * (0.5 + 1 / (0.5 + 0.5 + u[0]))
y[0] = 0.5 / (0.5 + 0.5 + u[0])
for i in range(1, 100):
    x[i] = u[i] * (x[i-1] + 1 / (x[i-1] + y[i-1] + u[i]))
    x[i] = round(x[i], 5)
    y[i] = x[i-1] / (x[i-1] + y[i-1] + u[i])
    y[i] = round(y[i], 5)

u_1 = np.zeros(100)
u_1[0] = 0.25
u_1[1:] = u[0:99]

data_uxy = np.array([u,x,y]).T
np.set_printoptions(precision=5)
# np.savetxt("data/data_uxy.txt", data_uxy,fmt="%.5f")

# print(data_uxy)


